// component/books/index.js
const API = require('../../utils/api');
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    data:Object,
  },
  /**
   * 组件的初始数据
   */
  data: {
    start:'',
    end:'',
    show:false,
    id:'',
    itemList: [
      {
        name: '删除',
        color:'#f00'
      }
    ],
  },

  /**
   * 组件的方法列表
   */
  methods: {
    onProduct: function(e){
      if (this.data.end - this.data.start < 500){
        var id = e.currentTarget.dataset.id;
        wx.navigateTo({
          url: '../read/index?id=' + id,
        })
      }
    },
    startClick:function(e){
      this.setData({start:e.timeStamp })
    },
    endClick:function(e){
      this.setData({end:e.timeStamp })
    },
    longClick: function(e){
      console.log(e)
      this.setData({
        show:true,
        id: e.currentTarget.dataset.id
      })
    },
    deleteBook: function(e){
      var self =this;
      var bookId = this.data.id; 
      var userId = wx.getStorageSync('id');
      API.deletebookshelf({
        bookId:bookId,
        userId:userId
      }).then(resp=>{
       
      })
    }
  },
  
})
